package com.lakeworks.web.controller.core;

import com.lakeworks.common.annotation.RoleAnnotation;
import com.lakeworks.common.core.controller.BaseController;
import com.lakeworks.common.core.domain.AjaxResult;
import com.lakeworks.common.domain.ticket.TktTicket;
import com.lakeworks.common.enums.UserRoleType;
import com.lakeworks.domain.OprPickup;
import com.lakeworks.mapper.TktTicketMapper;
import com.lakeworks.service.IOprIndexService;
import com.lakeworks.service.IOprPickupService;
import com.lakeworks.service.ITktTicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;

@RestController
@RequestMapping("/index")
@Validated
public class OprIndexController extends BaseController {

    @Autowired
    private IOprIndexService oprIndexService;

    @Autowired
    private ITktTicketService tktTicketService;


    @GetMapping("/monitor")
    @RoleAnnotation(UserRoleType.GLRY)
    public AjaxResult getMonitor() {
        return success(oprIndexService.getMonitorVo());
    }


    @GetMapping("/capacity")
    @RoleAnnotation(UserRoleType.GLRY)
    public AjaxResult getCapacity() {
        return success(oprIndexService.getCapacityVo());
    }


    @GetMapping("/ageing")
    @RoleAnnotation(UserRoleType.GLRY)
    public AjaxResult getAgeing() {
        return success(oprIndexService.getAgeingVo());
    }


    @GetMapping("/ticket/timeout")
    @RoleAnnotation(UserRoleType.GLRY)
    public AjaxResult getTimeout() {
        return success(tktTicketService.getTimeoutNum());
    }

    /**
     * 核查中未点入厂
     * param hour:1/6/12
     * */
    @GetMapping("/verify/count")
    @RoleAnnotation(UserRoleType.GLRY)
    public AjaxResult getVerifyCount(Integer hour){
        return success(oprIndexService.getVerifyCount(hour));
    }

    /**
     * 查询衣物时效监控数据
     * param
     * 已入厂待质检 state:TOWASH hour:36/48/72
     * 待配附件 state:ATTACH hour:6/12/24
     * 已质检待包装 state:TOWRAP hour:6/12/24
     * 已配附件待包装 state:WRAPPED hour:6/12/24
     * */
    @GetMapping("/product/count")
    @RoleAnnotation(UserRoleType.GLRY)
    public AjaxResult getProductCount(String state,Integer hour){
        return success(oprIndexService.getProductCount(state,hour));
    }


    /**
     * 查询出场单时效监控数据
     * param
     * 已有衣物上架待齐单 state:PENDING hour:24/48/72
     * 待打印拣货单 state:TOPICK hour:1/6/12
     * 拣货中未装箱 state:PICKING hour:1/6/12
     * 装箱中 state:PACKING hour:1/6/12
     * 已装箱待揽收出厂 state:PACKED hour:6/12/24
     * */
    @GetMapping("/shipment/count")
    @RoleAnnotation(UserRoleType.GLRY)
    public AjaxResult getshipmentCount(String state,Integer hour){
        return success(oprIndexService.getshipmentCount(state,hour));
    }

    /**
     * 已签收未入厂
     * param 开始时间 startHour:6/24/48  结束时间 endHour
     * */
    @GetMapping("/notReceived/count")
    @RoleAnnotation(UserRoleType.GLRY)
    public AjaxResult getNotReceivedCount(Integer startHour,Integer endHour){
        return success(oprIndexService.getNotReceivedCount(startHour,endHour));
    }

    /**
     * 客户服务超时
     * param days:5/7/10
     * */
    @GetMapping("/customer/timeout/count")
    @RoleAnnotation(UserRoleType.GLRY)
    public AjaxResult getCustomerTimeoutCount(Integer startDays,Integer endDays){
        return success(oprIndexService.getCustomerTimeoutCount(startDays,endDays));
    }

    /**
     * 生产管理超时
     * param days:3/5/7
     * */
    @GetMapping("/production/timeout/count")
    @RoleAnnotation(UserRoleType.GLRY)
    public AjaxResult getProductionTimeoutCount(Integer startDays,Integer endDays){
        return success(oprIndexService.getProductionTimeoutCount(startDays,endDays));
    }

    /**
     * 近十天出/入厂趋势
     * */
    @GetMapping("/tendency")
    @RoleAnnotation(UserRoleType.GLRY)
    public AjaxResult getTendency(){
        return success(oprIndexService.getTendency());
    }



}
